#include "app/app_message.h"
#include <assert.h>
#include <string.h>
#include <stdio.h>

int main(void)
{
    char str[] = "{\"connectType\":1,\"id\":\"0A0B\",\"mag\":\"AABBCCDDEEFF\"}";
    unsigned char bin[] = {0x01, 0x02, 0x06, 0x0A, 0x0B, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
    char buf[128];
    Message message;
    memset(&message,0,sizeof(Message));
    app_message_JosnTrunMessage(&message, str, strlen(str));
    int len = app_message_MessageTrunByte(&message, buf, 128);
    assert(len == 11);
    assert(memcmp(bin, buf, 11) == 0);
    
    app_message_free(&message);


    app_message_ByteTrunMessage(&message, bin, 11);
    app_message_MessageTrunJosn(&message, buf, 128);

    assert(strcmp(str, buf) == 0);
    app_message_free(&message);


    return 0;
}